// Dr Reese's lib.h
/* ============================================================ */
/* File: lib.h */
/* */
/* ============================================================ */
#ifndef LIB_H /* Avoid multiple inclusions */
#define LIB_H
/* ------------------------------------------------------------ */
/* A few data types to make the operand size more obvious. */
/* ------------------------------------------------------------ */
typedef int BOOL ;
typedef unsigned char BYTE8 ;
typedef unsigned short int WORD16 ;
typedef unsigned long int DWORD32 ;
typedef void (*ISR)(void) ; /* Pointer to an ISR */
#define BYTE unsigned char
#define WORD unsigned short
#define DWORD unsigned int
/* ------------------------------------------------------------ */
/* Constants for use with data type BOOL (above). */
/* ------------------------------------------------------------ */
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
/* ------------------------------------------------------------ */
/* Macros to extract the LSByte and MSByte of a WORD16 value */
/* ------------------------------------------------------------ */
#define LSB(u) ((u) & 0xFF)
#define MSB(u) ((u) >> 8)
/* ------------------------------------------------------------ */
/* Returns number of elements in an array. (Use in for loops.) */
/* ------------------------------------------------------------ */
#define ENTRIES(a) (sizeof(a)/sizeof(a[0]))
/* ------------------------------------------------------------ */
/* Declaration prefix to hide an object from the linker. */
/* ------------------------------------------------------------ */
#define PRIVATE static
/* ------------------------------------------------------------ */
/* Define a NULL pointer. */
/* ------------------------------------------------------------ */
#ifndef NULL
#define NULL ((void *) 0)
#endif
/* ------------------------------------------------------------ */
/* 386 instructions needed when writing ISR's. Note that IRET */
/* pops the pointer to the stack frame that was established by */
/* code that the compiler generates at every function entry. */
/* ------------------------------------------------------------ */
#define PUSHCS __asm__ __volatile__ ("PUSHL %CS") ;
#define PUSHF __asm__ __volatile__ ("PUSHFL")
#define POPF __asm__ __volatile__ ("POPFL")
#define STI __asm__ __volatile__ ("STI")
#define CLI __asm__ __volatile__ ("CLI")
#define PUSHA __asm__ __volatile__ ("PUSHAL")
#define POPA __asm__ __volatile__ ("POPAL")
#define ENTER __asm__ __volatile__ ("ENTER $0,$0")
#define LEAVE __asm__ __volatile__ ("LEAVE")
#define IRET __asm__ __volatile__ ("IRET")
/* ------------------------------------------------------------ */
/* Support for functions implemented in IO.ASM */
/* ------------------------------------------------------------ */
void outportb(WORD16, BYTE8) ;
BYTE8 inportb(WORD16) ;
int IRQ2INT(int irq) ;
ISR GetISR(int int_numb) ;
void SetISR(int int_numb, ISR isr) ;
/* ------------------------------------------------------------ */
/* Support for functions implemented in KEYBOARD.C */
/* ------------------------------------------------------------ */
BYTE8 GetScanCode(void) ;
BOOL ScanCodeRdy(void) ;
BOOL SetsKybdState(BYTE8) ;
WORD16 ScanCode2Ascii(BYTE8 code) ;
#endif
